#include <bits/stdc++.h>
#ifndef DEBUG
#define debug
#endif
using namespace std;
using i64 = int64_t;

void solve() {
  string str;
  cin >> str;
  stack<char> ops;
  string token;
  vector<string> tokens;
  int priority[128];
  priority[')'] = 0;
  priority['+'] = 1;
  priority['-'] = 1;
  priority['*'] = 2;
  priority['/'] = 2;
  priority['^'] = 3;
  priority['('] = 4;
  auto cmp = [&](int top, int cur) {
    if (top == '(') return cur == ')';
    return priority[top] >= priority[cur];
  };
  for (int i = 0; i < (int)str.size(); i ++) {
    char c = str[i];
    auto issign = [&](char c) {
      return (c == '-' || c == '+') && (i == 0 || (str[i - 1] != ')' && !isdigit(str[i - 1])));
    };
    if (isdigit(c) || issign(c)) {
      token += c;
    } else {
      if (!token.empty()) tokens.emplace_back(token);
      token.clear();
      while (!ops.empty() && cmp(ops.top(), c)) {
        if (ops.top() == '(' && c == ')') {
          ops.pop();
          break;
        }
        tokens.emplace_back(string(1, ops.top()));
        ops.pop();
      }
      if (c != ')') ops.push(c);
    }
  }
  if (!token.empty()) tokens.emplace_back(token);
  while (!ops.empty()) {
    if (ops.top() != '(') tokens.emplace_back(string(1, ops.top()));
    ops.pop();
  }

  stack<int> nums;
  auto calc = [&](char op) {
    int b = nums.top(); nums.pop();
    int a = nums.top(); nums.pop();
    if (op == '+') return a + b;
    if (op == '-') return a - b;
    if (op == '*') return a * b;
    if (op == '/') return a / b;
    return (int)pow(a, b);
  };
  for (auto token : tokens) {
    if (isdigit(token[token.size() - 1])) {
      nums.push(stoi(token));
    } else {
      nums.push(calc(token[0]));
    }
  }
  cout << nums.top() << endl;
}
int main() {
  cin.tie(0)->sync_with_stdio(0);
  int T = 1;
  // cin >> T;
  for (int cas = 1; cas <= T; cas ++) {
    solve();
  }
}